<div style="height: 300px">
    <div class="col-md-3" style="height: 100%;border: 1px solid #d8d8d8;">
        <div style="position: absolute;right:10px;font-size: 16px;"><b style="color: red">
                {{number_format($now_fees->sum('amount'),2)}} （元）</b></div>
        <div id="chart_now_fee" style="width: 100%;height:100%;">加载中....</div>
    </div>
    <div class="col-md-3" style="height: 100%;border: 1px solid #d8d8d8;" >
        <div style="position: absolute;right:10px;font-size: 16px;"><b style="color: #00a65a">{{$now_fees->sum('count')}} （个）</b></div>
        <div id="chart_now_count" style="width: 100%;height:100%;">加载中....</div>
    </div>
    <div class="col-md-3" style="height: 100%;border: 1px solid #d8d8d8;">
        <div style="position: absolute;right:10px;font-size: 16px;"><b style="color: red">{{number_format($next_fees->sum('amount'),2)}} （元）</b></div>
        <div id="chart_next_fee" style="width: 100%;height:100%;">加载中....</div>
    </div>
    <div class="col-md-3" style="height: 100%;border: 1px solid #d8d8d8;" >
        <div style="position: absolute;right:10px;font-size: 16px;"><b style="color: #00a65a">{{$next_fees->sum('count')}} （个）</b></div>
        <div id="chart_next_count" style="width: 100%;height:100%;">加载中....</div>
    </div>
</div>
<script>
    $(function () {
        var chart_now_count = echarts.init(document.getElementById('chart_now_count'),null,{renderer: 'canvas'});
        var chart_now_fee = echarts.init(document.getElementById('chart_now_fee'),null,{renderer: 'canvas'});
        var chart_next_fee = echarts.init(document.getElementById('chart_next_fee'),null,{renderer: 'canvas'});
        var chart_next_count = echarts.init(document.getElementById('chart_next_count'),null,{renderer: 'canvas'});
        chart_now_count.setOption({
            title: {
                text: "当年年费数量",
                left: 'left'
            },
            tooltip: {
                trigger: 'item',
                formatter: '{b} : {c} ({d}%)',
            },
            legend: {
                orient: 'vertical',
                left: 'left',
                data: []
            },
            series: [
                {
                    type: 'pie',
                    radius: '55%',
                    color: ['#7EC0EE', '#FF9F7F', '#FFD700', '#C9C9C9', '#E066FF', '#C0FF3E'],
                    data: [
                         @foreach($now_fees as $v)
                        {value: '{{$v->count??''}}', name: '{{$v->state?'已缴费':'未缴费'}}'},
                        @endforeach
                    ]
                }
            ]
        });
        chart_now_fee.setOption({
            title: {
                text: "当年年费金额",
                left: 'left',
            },
            tooltip: {
                trigger: 'axis',
                formatter: "{b} : {c} 元",
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    data: [
                        @foreach($now_fees as $fee)
                            @if($fee->state == 1)
                            '已交年费',
                            @elseif(!$fee->state)
                            '未缴年费',
                            @endif
                        @endforeach
                    ],
                    axisTick: {
                        alignWithLabel: true
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value'
                }
            ],
            series: [
                {
                    name: '应缴金额',
                    type: 'bar',
                    barWidth: '60%',
                    data: [
                        @foreach($now_fees as $fee)
                            '{{$fee->amount}}',
                        @endforeach
                    ]
                }
            ]
        });
        chart_next_count.setOption({
            title: {
                text: "次年年费数量",
                left: 'left'
            },
            tooltip: {
                trigger: 'item',
                formatter: '{b} : {c} ({d}%)',
            },
            legend: {
                orient: 'vertical',
                left: 'left',
                data: []
            },
            series: [
                {
                    type: 'pie',
                    radius: '55%',
                    color: ['#7EC0EE', '#FF9F7F', '#FFD700', '#C9C9C9', '#E066FF', '#C0FF3E'],
                    data: [
                            @foreach($next_fees as $v)
                        {value: '{{$v->count??''}}', name: '{{$v->state?'已缴费':'未缴费'}}'},
                        @endforeach
                    ]
                }
            ]
        });
        chart_next_fee.setOption({
            title: {
                text: "次年年费金额",
                left: 'left',
            },
            tooltip: {
                trigger: 'axis',
                formatter: "{b} : {c} 元",
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    data: ['未缴年费'],
                    axisTick: {
                        alignWithLabel: true
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value'
                }
            ],
            series: [
                {
                    type: 'bar',
                    barWidth: '60%',
                    data: [
                        @if($fees = $next_fees->pluck('amount','state'))
                            '{{$fees[0]??0}}'
                        @endif
                    ]
                }
            ]
        });
    });
</script>